package com.renwei.yunlong.base;

import android.app.Activity;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;

import com.zyf.fwms.commonlibrary.utils.AutoUtils;

import butterknife.ButterKnife;

/**
 * Created by Administrator on 2017/8/8.
 */

public abstract class BaseFragment extends Fragment {
    public Activity mActivity;

    //创建Fragment
    @Override
    public void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        mActivity = getActivity();//获得当前fragment所依赖的activity
    }

    //初始化fragment布局
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = initView();
        AutoUtils.setSize(mActivity, false, 720, 1280);
        AutoUtils.auto(view);
        return view;
    }

    //fragment所依赖的activity的onCreate方法执行结束
    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onActivityCreated(savedInstanceState);
        //初始化数据
        initData();
    }
    //初始化布局，必须由子类实现
    public abstract View initView();
    //初始化数据，必须由子类实现
    public abstract void initData();
}
